/*
 * AlbumBarController.fx
 *
 * Created on 9-jun-2009, 14:20:23
 */

package fotoboek.controls;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import fotoboek.assets.AlbumBar;
import fotoboek.Main;
import fotoboek.Constants;
import javafx.scene.image.Image;
import javafx.fxd.Duplicator;
import fotoboek.assets.stubs.albumTileUI;
import fotoboek.model.model.Album;

/**
 * @author r.mohammadi
 */


public class AlbumBarController extends CustomNode {
public-read var albumBar = AlbumBar{};

public function update(album : Album):Void{
    def albumBarUI = albumTileUI{};
    def d = Duplicator {};
    albumBar = AlbumBar{
            skin:d.duplicate(albumBarUI.skin) as Group
            nameText : album.name;
            captionText : Main.trimString(album.caption, 30);
            itemsText : "{album.items} Photo's |";
            ownerText : "By: {album.photographer}";
            album: album
            coverImage: Image{
                url:album.cover
                height: Main.config.ALBUM_COVER_HEIGHT
                width: Main.config.ALBUM_COVER_WIDTH
                backgroundLoading:true
                preserveRatio:false
                smooth:false
            }
            action : action
        }
 }

public var action = function():Void{};

    public override function create(): Node {
        return Group {
            content: bind albumBar.skin
        };
    }
}

